//
//  ChooseDoctorModel.m
//  KYProject
//
//  Created by Mxxx on 2016/12/22.
//  Copyright © 2016年 Roman. All rights reserved.
//

#import "ChooseDoctorModel.h"
#import <AFNetworking.h>
#import "NetWorkTool.h"
#import <YYModel.h>
#import "NetWorkDefine.h"
@implementation ChooseDoctorModel


- (NSString *)description
{
    return [self yy_modelDescription];
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{
    unsigned int count = 0;
    Ivar *ivars = class_copyIvarList([self class], &count);
    for (int i = 0; i < count; i++) {
        Ivar ivar = ivars[i];
        const char *name = ivar_getName(ivar);
        NSString *key = [NSString stringWithUTF8String:name];
        id value = [self valueForKey:key];
        [aCoder encodeObject:value forKey:key];
    }
    free(ivars);
}

//取
- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
    if (self = [super init]) {
        unsigned int count = 0;
        Ivar  *ivars = class_copyIvarList([self class], &count);
        for (int i = 0; i < count; i++) {
            Ivar ivar = ivars[i];
            const char *name = ivar_getName(ivar);
            NSString *key = [NSString stringWithUTF8String:name];
            id value = [aDecoder decodeObjectForKey:key];
            [self setValue:value forKey:key];
        }
        free(ivars);
    }
    return self;
}

#pragma mark
#pragma mark - 加载网络数据转化成模型数组

+(void)getModelList7WithComplete:(void (^)(NSArray<ChooseDoctorModel *> *, NSError *))completeBlock
{
    //七号借口
    NSString *urlString = @"http://iosapi.itcast.cn/matchDoctors.json.php";
    NSDictionary *paramDic = @{@"ci1_id":@1,
                               @"ci2_id":@3,
                               @"ci3_id":@3,
                               @"diagnosis_type":@0,
                               @"page_size":@15,
                               @"is_confirmed":@1,
                               @"user_id":@1000089,
                               @"page":@1,
                               @"has_diagnosis":@2
                               };
    
    [[NetWorkTool shareManager] POST_RequestWithUrlString:urlString parmas:paramDic successBloock:^(NSDictionary * responseObject) {
        NSArray *arr =responseObject[@"data"];
        NSArray<ChooseDoctorModel *> *modelList = [NSArray yy_modelArrayWithClass:[ChooseDoctorModel class] json:arr];
        completeBlock(modelList,nil);
               // NSLog(@"responseObject = %@",responseObject);
    } failureBlock:^(NSError *error) {
        completeBlock(nil,error);
        NSLog(@"error = %@",error);
    }];
}

//获取关注医生列表接口
+ (void)getModelList13WithComplete:(void(^)(NSArray<ChooseDoctorModel *> *modelList,NSError *error))completeBlock{
        
        //    15号借口
        NSString *urlString = kDoctorListUrl;
        NSDictionary *paramDic = @{
                                   @"user_id":@"1000089",
                                   @"page_size":@15,
                                   @"page":@1
                                   };
        
        [[NetWorkTool shareManager] POST_RequestWithUrlString:urlString parmas:paramDic successBloock:^(NSDictionary * responseObject) {
            NSArray *arr =responseObject[@"data"];
            NSArray<ChooseDoctorModel *> *modelList = [NSArray yy_modelArrayWithClass:[ChooseDoctorModel class] json:arr];
            completeBlock(modelList,nil);
            //        NSLog(@"responseObject = %@",responseObject);
        } failureBlock:^(NSError *error) {
            completeBlock(nil,error);
            NSLog(@"error = %@",error);
        }];
        
}

////获取关注医生列表接口
//+ (void)getModelList15WithComplete:(void (^)(NSArray<ChooseDoctorModel *> *, NSError *))completeBlock
//{
//    NSString *urlString = @"http://iosapi.itcast.cn/doctorList.json.php";
//    NSDictionary *paramDic = @{}
//}
@end
